// VS_BEGIN
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aCoord;
layout (location = 2) in vec3 aNormal;

uniform mat4 u_model;

out vec2 g_coord;

layout (std140) uniform EngineUBO
{
    mat4    u_view;
    mat4    u_project;
    vec3    u_camPos;
    vec3    u_camInfo;
};

uniform float u_scale = 1.0f;

void main() {
    mat4 model = u_model;
	float distanceToCamera = distance(u_camPos, model[3].xyz);
    mat4 modelView = u_view * u_model;

    // Column 0:
    modelView[0][0] = 1;
    modelView[0][1] = 0;
    modelView[0][2] = 0;

    // Column 1:
    modelView[1][0] = 0;
    modelView[1][1] = 1;
    modelView[1][2] = 0;

    // Column 2:
    modelView[2][0] = 0;
    modelView[2][1] = 0;
    modelView[2][2] = 1;

    gl_Position = u_project * modelView * vec4(aPos * distanceToCamera * u_scale, 1.0);
    g_coord = aCoord;
}
// VS_END

// FS_BEGIN
#version 330 core

out vec4 FragColor;

in vec2 g_coord;

uniform sampler2D u_texture;
uniform float u_id;

void main() {
    if (u_id == 0.0f) {
        FragColor = texture(u_texture, g_coord);
    } else {
        FragColor = vec4(u_id, 0.0f, 0.0f, 1.0f);
    }
}
// FS_END